//
//  FHTabBarSearchView.m
//  FeiHuNote
//
//  Created by N-X on 2017/11/9.
//  Copyright © 2017年 MRNAN. All rights reserved.
//

#import "FHNavigationBarSearchView.h"
#import "UIViewController+Utils.h"
//#import <PYSearchViewController.h>

@interface FHNavigationBarSearchView()/*<PYSearchViewControllerDelegate> */
@property (nonatomic ,strong)UIButton * searchBarButton;
@end
@implementation FHNavigationBarSearchView

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        UIButton * searchBarButton = [UIButton buttonWithType:UIButtonTypeCustom];
        searchBarButton.frame = frame;
        [searchBarButton setImage:[UIImage imageNamed:@"Home_SearchIcon"] forState:UIControlStateNormal];
        [searchBarButton setImage:[UIImage imageNamed:@"Home_SearchIcon"] forState:UIControlStateHighlighted];
        [searchBarButton setBackgroundImage:[UIImage imageNamed:@"Home_SearchBarBackground"] forState:UIControlStateNormal];
        [searchBarButton setBackgroundImage:[UIImage imageNamed:@"Home_SearchBarBackground"] forState:UIControlStateHighlighted];
        [searchBarButton setTitle:@"搜索" forState:UIControlStateNormal];
        [searchBarButton setTitleColor:NX_ColorFromRGB(178, 178, 178) forState:UIControlStateNormal];
        searchBarButton.titleLabel.font = [UIFont fontWithName:@"PingFangSC-Regular" size:13];
        [searchBarButton addTarget:self action:@selector(pushSearchVC) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:searchBarButton];
        self.searchBarButton = searchBarButton;
    }
    return self;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    self.searchBarButton.frame = self.bounds;
}
//- (CGSize)intrinsicContentSize
//{
//    return UILayoutFittingExpandedSize;
//}

#pragma mark - 事件处理
- (void)pushSearchVC
{
//    NSArray *hotSeaches = @[@"Java", @"Python", @"Objective-C", @"Swift", @"C", @"C++", @"PHP", @"C#", @"Perl", @"Go", @"JavaScript", @"R", @"Ruby", @"MATLAB"];
//    PYSearchViewController *searchViewController = [PYSearchViewController searchViewControllerWithHotSearches:hotSeaches searchBarPlaceholder:@"Search programming language" didSearchBlock:^(PYSearchViewController *searchViewController, UISearchBar *searchBar, NSString *searchText) {
//
//        [searchViewController.navigationController pushViewController:[[UIViewController alloc] init] animated:YES];
//
//    }];
//    searchViewController.delegate = self;
//    searchViewController.searchHistoryStyle = PYSearchHistoryStyleBorderTag;
//    UIViewController * currentVC = [UIViewController currentViewController];
//    currentVC.hidesBottomBarWhenPushed = YES;
//    [currentVC.navigationController pushViewController:searchViewController animated:YES];
//    currentVC.hidesBottomBarWhenPushed = NO;
}

@end
